<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>打卡记录修改</title>
    <base th:href="${#request.getContextPath()}+'/'">
    <link rel="stylesheet" href="/static/layui/css/layui.css" th:href="@{/static/layui/css/layui.css}">

    <style type="text/css">

    </style>
</head>

<body style="width: 800px;height: 600px;">
<!--编辑表单-->
<div id="editBook">
    <form class="layui-form" id="saveBook" style="margin-top:10px">
        <input type="hidden" name="id" id="id" th:value="${card001.id}">

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">医生工号</label>
                <div class="layui-input-inline">
                    <input type="text" name="workerId" id="workerId" required lay-verify="workerId" autocomplete="off"
                           class="layui-input" placeholder="必填" th:value="${card001.workerId}" readonly>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">医生姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" id="name" required lay-verify="required" autocomplete="off"
                           class="layui-input" placeholder="必填" th:value="${card001.name}" readonly>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">其余补充</label>
                <div class="layui-input-block">
                    <textarea name="extend" required lay-verify="required" placeholder="请输入内容" class="layui-textarea" th:text="${card001.extend}"></textarea>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">健康码状态</label>
                <div class="layui-input-inline">
                    <select name ="heathCodeState" lay-filter="levelM" lay-verify="required">
                        <option value ="0" th:field="*{card001.heathCodeState}">绿色</option>
                        <option value ="1" th:field="*{card001.heathCodeState}">黄色</option>
                        <option value ="2" th:field="*{card001.heathCodeState}">红色</option>
                        <option value ="3" th:field="*{card001.heathCodeState}">其它</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">身体状态</label>
                <div class="layui-input-inline">
                    <select name ="bodyState" lay-filter="levelM" lay-verify="required" >
                        <option value ="0" th:field="*{card001.bodyState}">健康</option>
                        <option value ="1" th:field="*{card001.bodyState}">有发烧、咳嗽、咽痛、腹泻、乏力、鼻塞、流涕等症状</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">提交时间</label>
                <div class="layui-input-inline">
                    <input type="date" name="submitDay" id="submit_day" required autocomplete="off"
                           class="layui-input"
                           lay-verify="required" th:value="${#dates.format(card001.submitDay,'yyyy-MM-dd')}" readonly>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">居住地址</label>
                <div class="layui-input-inline">
                    <input lay-verify="required" type="text" name="addressOfHome" id="addressOfHome"
                           autocomplete="off"
                           placeholder="x省-x市-x县/区"
                           th:value="${card001.addressOfHome}"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">今日体温(℃)</label>
                <div class="layui-input-inline">
                    <input type="text" name="temperatureToday" id="temperatureToday" required lay-verify="temperatureToday" autocomplete="off"
                           class="layui-input" placeholder="必填" th:value="${card001.temperatureToday}">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">联系方式</label>
                <div class="layui-input-inline">
                    <input type="text" name="phoneNumber" id="phoneNumber" required lay-verify="phone" autocomplete="off"
                           class="layui-input" placeholder="必填" th:value="${card001.phoneNumber}">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">近14天到达风险地区</label>
                    <div class="layui-input-block">
                        <input type="radio" name="inDangerousPlace" th:value="1" th:checked="${card001.inDangerousPlace==1}" title="是">
                        <input type="radio" name="inDangerousPlace" th:value="0" th:checked="${card001.inDangerousPlace==0}" title="否">
                    </div>
            </div>
        </div>
        <div class="layui-form-item" style="margin-top:40px" id="check">
            <div class="layui-input-block">
                <button class="layui-btn  layui-btn-submit " lay-submit="" lay-filter="saveBook">保存</button>
                <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
            </div>
        </div>
    </form>
</div>


<script src="/static/js/jquery-1.11.3.min.js" th:src="@{/static/js/jquery-1.11.3.min.js}"></script>
<script src="/static/layui/layui.all.js" th:src="@{/static/layui/layui.all.js}"></script>
<script src="/static/js/util.js" th:src="@{/static/js/util.js}"></script>

<!--ctx-->
<script th:replace="~{fragment::ctx}"/>

<script>
    var element, layer, laydate, form;

    $(function () {

        // 使用模块
        layui.use(['element', 'layer', 'laydate', 'form'], function () {
            element = layui.element;
            layer = layui.layer;
            laydate = layui.laydate;
            form = layui.form;
        });

        form.verify({
            integer:[
                /^[0-9]\d*$/
                ,'只能输入整数！'
            ],
            temperatureToday: function (value) {
                if (value.length === 4
                    &&value.charAt(2) === '.'
                    && value.charAt(0) <= '9'&& value.charAt(0) >= '0'
                    && value.charAt(1) <= '9'&& value.charAt(1) >= '0'
                    && value.charAt(3) <= '9'&& value.charAt(3) >= '0'){
                }else {
                    return '温度格式不合法！请按提示要求。';
                }
            },
            phoneNumber: function (value){
                if(value.length === 11
                    && value.charAt(0) <= '9'&& value.charAt(0) >= '0'
                    && value.charAt(1) <= '9'&& value.charAt(1) >= '0'
                    && value.charAt(2) <= '9'&& value.charAt(2) >= '0'
                    && value.charAt(3) <= '9'&& value.charAt(3) >= '0'
                    && value.charAt(4) <= '9'&& value.charAt(4) >= '0'
                    && value.charAt(5) <= '9'&& value.charAt(5) >= '0'
                    && value.charAt(6) <= '9'&& value.charAt(6) >= '0'
                    && value.charAt(7) <= '9'&& value.charAt(7) >= '0'
                    && value.charAt(8) <= '9'&& value.charAt(8) >= '0'
                    && value.charAt(9) <= '9'&& value.charAt(9) >= '0'
                    && value.charAt(10) <= '9'&& value.charAt(10) >= '0'){
                }else {
                    return '手机号码格式错误！（11位数字）';
                }
            },
            workerId: function (value){
                if (value.length === 7
                    && value.charAt(0) <= '9'&& value.charAt(0) >= '0'
                    && value.charAt(1) <= '9'&& value.charAt(1) >= '0'
                    && value.charAt(2) <= '9'&& value.charAt(2) >= '0'
                    && value.charAt(3) <= '9'&& value.charAt(3) >= '0'
                    && value.charAt(4) <= '9'&& value.charAt(4) >= '0'
                    && value.charAt(5) <= '9'&& value.charAt(5) >= '0'
                    && value.charAt(6) <= '9'&& value.charAt(6) >= '0'){
                }else {
                    return '工号格式错误！（7位数字）';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });


        //监听表单提交
        // 修改
        form.on('submit(saveBook)', function (data) {

            $.ajax({
                url: ctx+'api/card001/update',
                type: 'POST',
                contentType: "application/json",
                dataType: "json",
                data: JSON.stringify(data.field),
                success: function (result) {
                    if (result.code === 200) {
                        cleanForm("#saveBook");
                        top.layer.closeAll();//关闭所有的弹出层
                        top.$(".layui-show").find("iframe")[0].contentWindow.userTable.reload();
                    } else {
                        layer.alert(result.message);
                    }
                }
            });

            return false;

        });
    });


</script>
</body>

</html>